package com.atguigu.dga.governance.service.impl;

import com.atguigu.dga.governance.service.*;
import com.atguigu.dga.meta.service.impl.TableMetaInfoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Service
public class MainAssessServiceImpl implements MainAssessService {
    @Autowired
    GovernanceAssessTableService governanceAssessTableService;
    @Autowired
    GovernanceAssessGlobalService governanceAssessGlobalService;
    @Autowired
    GovernanceAssessTecOwnerService governanceAssessTecOwnerService;
    @Autowired
    TableMetaInfoServiceImpl tableMetaInfoService ;
    @Autowired
    GovernanceAssessDetailService governanceAssessDetailService;
    @Value("${assess.schema}")
    private String assessSchema;

    @Scheduled(cron = "* 4 9 * * *")
    public void mainAssess() throws Exception {
        String assessDate="2023-05-02";
        //元数据采集
        tableMetaInfoService.initTableMetaInfo("assessSchema",assessDate);
        //考评
        governanceAssessDetailService.mainAssess(assessDate);
        //打分
        governanceAssessTableService.calcGovernanceTableScore(assessDate);
        governanceAssessGlobalService.calcGovernanceAssessGlobal(assessDate);
        governanceAssessTecOwnerService.calcTecOwnerScore(assessDate);
    }

    @Override
    public void getAssessService(String assessDate) throws Exception {
        //元数据采集
        tableMetaInfoService.initTableMetaInfo("assessSchema",assessDate);
        //考评
        governanceAssessDetailService.mainAssess(assessDate);
        //打分
        governanceAssessTableService.calcGovernanceTableScore(assessDate);
        governanceAssessGlobalService.calcGovernanceAssessGlobal(assessDate);
        governanceAssessTecOwnerService.calcTecOwnerScore(assessDate);
    }
}
